package com.controller.setting;

import com.comm.R;
import com.service.setting.SysPrescriptionService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;

@RequestMapping(value = "/systemPrescription")
@Controller
@Api(value = "处方附加费",tags = "处方附加费接口")
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=403,message="请求禁止"),
        @ApiResponse(code=401,message="请求未授权"),
        @ApiResponse(code=500,message="后台服务错误")})
public class SystemPrescription {
    @Autowired
    private SysPrescriptionService sysPrescriptionService;
    //1.1.1：条件查找处方费
    @ResponseBody
    @RequestMapping(value ="/fundPrescription",method = RequestMethod.GET)
    @ApiOperation(value = "条件查询处方附加费的接口",notes = "条件查询处方附加费",httpMethod = "post", response = String.class)
    @ApiImplicitParam(name = "costname",value = "挂号类型",required = true,dataType = "String",paramType = "query")
    public  R fundPrescription(@RequestParam(name = "costname")String  costname){
        R r = new R();
        r.setCode(200);
        r.setMsg("你好棒，查到了");
        String data = "{\n" +
                " \"data\": [{\n" +
                "   \"id\": 100001,\n" +
                "   \"costname\": \"敌敌畏\",\n" +
                "   \"costmoney\": 50,\n" +
                "   \"prescriptiontype\": \"中药处方\",\n" +
                "  }\n" +
                " ]}";
        r.setData(data);
        return r;
    }
    //1.1.2：查找处方费
    @ResponseBody
    @RequestMapping(value ="/fundPrescriptions",method = RequestMethod.GET)
    @ApiOperation(value = "查询处方附加费的接口",notes = "查询处方附加费",httpMethod = "post", response = String.class)
    public  R fundPrescriptions(){

        return sysPrescriptionService.fundPrescriptions();
    }
//   1.2.3：添加处方附加费的接口：
    @ResponseBody
    @RequestMapping(value ="/addPrescriptions",method = RequestMethod.POST)
    @ApiOperation(value = "添加处方附加费的接口",notes = "添加处方附加费",httpMethod = "post", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "costname",value = "费用名称",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "costmoney",value = "金额",paramType = "query",dataType = "double",required = true),
            @ApiImplicitParam(name = "prescriptiontype",value = "处方类型",paramType = "query",dataType = "String",required = true)
    })
    public  R addPrescriptions(@RequestParam(name = "costname")String costname, @RequestParam(name = "costmoney") BigDecimal costmoney, @RequestParam(name = "prescriptiontype")String prescriptiontype){
        R r = new R();
        r.setCode(200);
        r.setMsg("你好棒，添加成功");
        String data = "";
        r.setData(data);
        return r;
    }
    // 1.2.4：编辑处方附加费的接口：
    @ResponseBody
    @RequestMapping(value ="/editPrescriptions",method = RequestMethod.POST)
    @ApiOperation(value = "编辑处方附加费的接口",notes = "编辑处方附加费",httpMethod = "post", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "主键ID",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "costname",value = "费用名称",paramType = "query",dataType = "string",required = true),
            @ApiImplicitParam(name = "costmoney",value = "金额",paramType = "query",dataType = "double",required = true),
            @ApiImplicitParam(name = "prescriptiontype",value = "处方类型",paramType = "query",dataType = "String",required = true)
    })
    public  R editPrescriptions(@RequestParam(name = "id")Integer id, @RequestParam(name = "costname") String costname, @RequestParam(name = "costmoney")BigDecimal costmoney,@RequestParam("prescriptiontype") String prescriptiontype){
        R r = new R();
        r.setCode(200);
        r.setMsg("你好棒，编辑成功");
        String data = "";
        r.setData(data);
        return r;
    }
    // 1.2.5：删除处方附加费的接口：
    @ResponseBody
    @RequestMapping(value ="/deltPrescriptions",method = RequestMethod.POST)
    @ApiOperation(value = "删除处方附加费的接口",notes = "删除处方附加费",httpMethod = "post", response = String.class)
    @ApiImplicitParam(name = "id",value = "用户id",required = true,dataType = "int",paramType = "query")
    public  R delPrescriptions(@RequestParam(name = "id")Integer id){
        R r = new R();
        r.setCode(200);
        r.setMsg("你好棒，删除成功");
        String data = "";
        r.setData(data);
        return r;
    }
}
